#include "extractorBoundaryCenterVector.h"

extractorBoundaryCenterVector::extractorBoundaryCenterVector(char* _labelImage, Slic _clustering){
	this->labelImage = _labelImage;
	this->size = _clustering.getCenter_counts().size();

	Mat _cluster = _clustering.convertClustersToMat();
	int _nHist = 2;

	cout << _cluster.rows << " " << _cluster.cols << endl;

	for(int icluster = 0; icluster < size; icluster++){

		boundaryCenterVector _boundaryCenterVect(2,icluster,_labelImage);
		cv::vector<uchar> _initialVect(2,0);
		_boundaryCenterVect.addValue(_initialVect);

		if(_cluster.at<int>(_cluster.rows / 2,_cluster.cols/2) == icluster){
			// center
			_boundaryCenterVect.setValue(0,1);
		}

		for(int i = 0; i < _cluster.rows; i++){
			if(_cluster.at<int>(i,0) == icluster){
				// boundary
				_boundaryCenterVect.setValue(1,1);
			}
			if(_cluster.at<int>(i,_cluster.cols) == icluster){
				// boundary
				_boundaryCenterVect.setValue(1,1);
			}
		}
		for(int j = 0; j < _cluster.cols; j++){
			if(_cluster.at<int>(0,j) == icluster){
				// boundary
				_boundaryCenterVect.setValue(1,1);
			}
			if(_cluster.at<int>(_cluster.rows,j) == icluster){
				// boundary
				_boundaryCenterVect.setValue(1,1);
			}
		}

		this->listVector.push_back(_boundaryCenterVect);
	}
}

vector<boundaryCenterVector> extractorBoundaryCenterVector::getListVector() {
	return this->listVector;
}